﻿#include <iostream>
#include <string>
#include <string.h>
#include <sstream>

#include "Link.h"
using namespace std;
struct student
{
    std::string name;
    char sex;
    int score;
};

string int2str(const int &int_temp)
{
    stringstream stream;
    stream<<int_temp;
    string string_temp;
    string_temp=stream.str();   //此处也可以用 stream>>string_temp
    return string_temp;
}

int main()
{
    student s[10]={{"zhang",'m',0}};
    for(int i=0; i<10;i++)
    {
        s[i].name = "zhang"+int2str(i);
        s[i].score=i;
        if(i%3)
            s[i].sex = 'f';
        else {
            s[i].sex = 'm';
        }
    }
    Link<student> link;
    for(int i=0; i<10; i++)
    {
        link.insert(i,s[i]);
    }

    Node<student>* node=link.getHead();
    while(node)
    {
        std::cout<<node->value.name<<" "<<node->value.sex<<" "<<node->value.score<<"\n";
        node=node->next;
    }
    std::cout<<"\n";

    Node<student>* node1=link.getHead();
    int count=0;
    while(node1)
    {
        count++;
        if(node1->value.sex == 'f')
        {
            node1=link.del(count);
            count--;
        }
        else
            node1=node1->next;

    }

    Node<student>* node2=link.getHead();
    while(node2)
    {
        std::cout<<node2->value.name<<" "<<node2->value.sex<<" "<<node2->value.score<<"\n";
        node2=node2->next;
    }
}


